<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2018/4/18
 * Time: 20:22
 */

namespace app\widgets;


use app\models\Post;
use yii\base\Widget;

class PostRelatedWidget extends Widget {

    public $limit = 9;
    public $view = '/widget/post';
    public $cid;

    public function run() {
        $models = Post::find()->where(['cid' => $this->cid])->limit($this->limit)->asArray()->all();
        return $this->render($this->view, compact('models'));
    }
}